% function [v_v_out,fre_offset]= V_V_fre(CMA_out)
% scatterplot(v_v_out);
close all
v_v_out2 = v_v_out.*exp(1i*1);
scatterplot(v_v_out2);
title("未恢复的星座图Viterbi-Viterbi")
total_angle = 0;
for i = 2:length(v_v_out2)
    dn = v_v_out2(i);
    dn4 = dn.^4;
    cur_angle = angle(dn4);
    % if cur_angle<0
    %     cur_angle=cur_angle+2*pi;
    % end
    
    total_angle  = total_angle+cur_angle;
end
avgangle = total_angle/(length(2:length(v_v_out2)));
avgangle
% v_v_out = v_v_out.*exp(1i*(1:length(CMA_out))*(-avgangle));
phase_out = v_v_out2.*exp(-1i*(avgangle));
scatterplot(phase_out);
title("恢复的星座图Viterbi-Viterbi")
%%
close all
v_v_out2 = v_v_out;
scatterplot(v_v_out2);
title("未恢复的星座图")
total = 0;
for i = 2:length(v_v_out2)
    dn = v_v_out2(i);
    dn4 = dn.^4;
    total = total+dn4;
end
total
avgangle = (angle(total)-pi)/4;
% v_v_out = v_v_out.*exp(1i*(1:length(CMA_out))*(-avgangle));
phase_out = v_v_out2.*exp(-1i*(avgangle));
scatterplot(v_v_out2);
scatterplot(phase_out);
title("恢复的星座图Viterbi-Viterbi")